/**
 * Created by seeker910 on 2018/5/17.
 */

Rsd.define('Rsd.Faith.pages.FiscalDTPiaoJuXinXiListPage', {
    extend: 'Rsd.Faith.pages.ListPage',
    requires: ['Rsd.controlEx.ComboBoxEnum','Rsd.Faith.controls.SuoShuQiInput'],
    xtype: 'list-dt-piaoJu',
    border: false,
    tabTitle: '电梯消防设备维修资金缴存信息',
    searchColumns:[
        {name:'SuoShuQi',text:'所属期',width:250,xtype:'ctrl-suoshuqi'},
        {name:'YeZhuXingMing',text:'小区名称',width:250},
        {name:'FangWuDaiMa',text:'发票编号',width:250},
        {name:'ZhuangTai',text:'状态',width:250, "xtype": "combobox-enum", "enum":"Rsd.Faith.Core.FaPiaoZhuangTai"}
        ],
    modelType: 'FiscalPiaoJuXinXiDtBiaoModel',
    formFields: [
        {
            "name": "FaPiaoBianHao",
            "label": {
                "text": "发票编号",
                "width": 80
            },
            "xtype": "text"
        },
        {
            readOnly:true,
            "name": "ZhuangTai",
            "label": {
                "text": "状态",
                "width": 80
            },
            "xtype": "text"
        },


        {
            "name": "FangWuXingZhi",
            "label": {
                "text": "房屋性质",
                "width": 80
            },
            "xtype": "text"
        },
        {
            "name": "FangWuLeiXing",
            "label": {
                "text": "房屋类型",
                "width": 80
            },
            "xtype": "text"
        },
        {
            "name": "ShouFeiBiaoZhun",
            "label": {
                "text": "收费标准",
                "width": 80
            },
            "xtype": "combobox-enum",
            enum:'ShouFei_BiaoZhun_DT'
        },
        {
            "name": "YingJiaoJinE",
            "label": {
                "text": "应交金额",
                "width": 80
            },
            "xtype": "number",
            "precision": 2
        },
        {
            "name": "KaiPiaoXiangMu",
            "label": {
                "width": 80,
                "content": "开票项目"
            },
            "dataIndex": "KaiPiaoXiangMu",
            "index": 10,
            "exist": true,
            "xtype": "text",
            "length": 120
        },
        {
            "name": "FaPiaoJinE",
            "label": {
                "width": 80,
                "content": "发票金额"
            },
            "dataIndex": "FaPiaoJinE",
            "index": 11,
            "exist": true,
            "xtype": "number",
            "precision": 2
        },
        {
            "name": "JiaoNaRiQi",
            "label": {
                "text": "交纳日期",
                "width": 80
            },
            "xtype": "date",
            "formatString": "yyyy-MM-dd"
        },

        {
            "name": "CaoZuoYuanHao",
            "label": {
                "text": "开票人",
                "width": 80
            },
            "xtype": "text"
        },



        {
            "name": "Remark",
            "label": {
                "text": "备注",
                "width": 80
            },
            "xtype": "text"
        }
    ],
    gridColumns: [
        {
            "text": "序号",
            "xtype": "index",
            "width": 60,
            "sortable": false
        },
        {
            "name": "FaPiaoBianHao",
            "text": "发票编号",
            "dataindex": "FaPiaoBianHao",
            "sortable": false,
            align:'right',
            "width": 150,
            "nobr": true,
            format:'format_fph'
        },
        {
            "name": "SuoShuQi",
            "dataIndex": "SuoShuQi",
            "sortable": false,
            "text": "所属期",
            align:'center',
            "index": 20,
            "exist": true,
            "xtype": "string",
            "width": 80,
            "nobr": true
        },
        {

            "name": "ZhuangTai",
            "text": "状态",
            "dataindex": "ZhuangTai",
            "sortable": false,
            align:'center',
            "width": 80,
            xtype:'enum',
            enum:'PiaoJu_ZhuangTai_DT',
            "nobr": true
        },
        {
            "name": "KaiFaDaiMa",
            text:"开发商",
            "sortable": false,
            "dataIndex": "KaiFaDaiMa",
            "width": 70,
            "length": 20
        },
        {
            "name": "XiaoQuMingCheng",
            "text": "小区",
            "dataindex": "XiaoQuMingCheng",
            "sortable": false,
            align:'center',
            "width": 70,
            "nobr": true
        },
        {
            "name": "LouDongHao",
            "text": "楼栋",
            "dataindex": "LouDongHao",
            "sortable": false,
            align:'center',
            "width": 70,
            "nobr": true
        },
       {
            "name": "FangWuXingZhi",
            "text": "房屋性质",
            "dataindex": "FangWuXingZhi",
            "sortable": false,
            "width": 70,
            "nobr": true,
            xtype:'enum',
             "enum":"FangWo_XingZhi"
        },
        {
            "name": "FangWuLeiXing",
            "text": "房屋类型",
            "dataindex": "FangWuLeiXing",
            "sortable": false,
            align:'center',
            "width": 70,
            xtype:'enum',
            "enum":"FangWo_LeiXing",
            "nobr": true
        },

        {
            "xtype": "enum",
            enum:'ShouFei_BiaoZhun_DT',
            "name": "ShouFeiBiaoZhun",
            "text": "收费标准",
            "dataindex": "ShouFeiBiaoZhun",
            "sortable": false,
            align:'center',
            "width": 70,
            "nobr": true
        },

        {
            "name": "YingJiaoJinE",
            "text": "应交金额",
            "dataindex": "YingJiaoJinE",
            "sortable": false,
            "xtype": "number",
            "width": 100,
            "precision": 2
        },
        {
            "name": "FaPiaoJinE",
            "text": "实交金额",
            "dataindex": "FaPiaoJinE",
            "sortable": false,
            "xtype": "number",
            "width": 100,
            "precision": 2
        },
        {
            "name": "JiaoNaRiQi",
            "text": "交纳日期",
            "dataindex": "JiaoNaRiQi",
            "sortable": true,
            sortDirection:"desc",
            "xtype": "date",
            "formatString": "yyyy-MM-dd",
            "width": 120
        },

        {
            "name": "CaoZuoYuanHao",
            "text": "开票人",
            "dataindex": "CaoZuoYuanHao",
            "sortable": false,
            "width": 70,
            "nobr": true
        },
        {
            "name": "Remark",
            "text": "备注",
            "dataindex": "Remark",
            "sortable": false,
            "width": 100,
            "nobr": true
        }
    ],
    titleField : 'FaPiaoBianHao',
    /*
     * */
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
    },
    /*
     * */
    format_fph:function format_fph(row)
    {
        if(Rsd.isEmpty(row))
        {
            return [];
        }
        if(row['ZhuangTai'] == '已登记')
        {
            var _fn = function () {
                Rsd.create('Rsd.Faith.dialogs.FiscalDTShengHeDialog',{}).showDialog().load(row);
            };
            var _btn = Rsd.button('审核',_fn);
            _btn.title = '审核发票(' + row['FaPiaoBianHao'] + ')资金是否缴存到银行账户（专户）。'
            return [Rsd.blankspan(2),_btn,Rsd.blankspan(1),Rsd.btn('建账')];
        }
        if(row['ZhuangTai'] == '已到账')
        {
            var _fn = function () {
                alert('将发票(' + row['FaPiaoBianHao'] + ')缴存资金按小区楼栋及各单元面积计入明细账。');
            };
            var _btn = Rsd.button('建账',_fn);
            return [Rsd.blankspan(2),Rsd.button('建账',_fn)];
        }
        return [];
    }

});